package hot100;

public class swapPairs2 {
    public mergeKLists.ListNode swapPairs(mergeKLists.ListNode head) {
        mergeKLists.ListNode cur = new mergeKLists.ListNode(0,head);
        mergeKLists.ListNode ret = cur;
        while(cur.next != null && cur.next.next != null) {
            mergeKLists.ListNode node1 = cur.next;
            mergeKLists.ListNode node2 = cur.next.next;
            cur.next = node2;
            node1.next = node2.next;
            node2.next = node1;
            cur = node1;
        }
        return ret.next;

    }
}
